<template>
	<view :style="[{paddingTop:CustomBar+'px'}]">
		<cu-custom bgColor="bg-colorP" :isBack="true"> 
			<block slot="backText"></block>
			<block slot="content">{{navTitle}}</block>
		</cu-custom>
		<view class="ticket-content">
			<view class="tab-view">
				<view v-for="(item,index) in tabbar" :key="index" class="tab-bar-item" :class="[currentTab==index ? 'active' : '']"
				 :data-current="index" @tap.stop="swichNav">{{item}}</view>
			</view>
			<swiper class="tab-content" :current="currentTab" duration="300" @change="switchTab" :style="{height:winHeight+'px'}">
				<swiper-item>
					<scroll-view scroll-y class="scoll-y">
						<view class="cu-bar bg-white">
							<view class="action" style="margin-left: 0;">
								<text class="text-xl text-bold text-black">开放时间</text>
							</view>
						</view>
						<view class="time h-time">
							<view>
								旺季
							</view>
							<view>
								{{shopInfo.start_time}}~{{shopInfo.end_time}}
							</view>
						</view>
						<view class="time">
							<view>
								淡季
							</view>
							<view>
								{{shopInfo.start_time}}~{{shopInfo.end_time}}
							</view>
						</view>
						<view class="cu-bar bg-white" v-if="shopInfo.tips.value.tips_best_time.value">
							<view class="action" style="margin-left: 0;">
								<text class="text-xl text-bold text-black">游玩时间</text>
							</view>
						</view>
						<view class="ac-time" v-if="shopInfo.tips.value.tips_best_time.value">
							{{shopInfo.tips.value.tips_best_time.value}}
						</view>
						<view class="cu-bar bg-white" v-if="shopInfo.tips.value.tips_play_time.value">
							<view class="action" style="margin-left: 0;">
								<text class="text-xl text-bold text-black">建议时长</text>
							</view>
						</view>
						<view class="ac-time" v-if="shopInfo.tips.value.tips_play_time.value">
							{{shopInfo.tips.value.tips_play_time.value}}
						</view>
						<view class="cu-bar bg-white">
							<view class="action" style="margin-left: 0;">
								<text class="text-xl text-bold text-black">优待政策</text>
							</view>
						</view>
						<view class="ac-time">
							<text>免票</text>
							<text>65岁（含）以上老人，1.2m（不含）以下儿童</text>
						</view>
						<view class="ac-time">
							<text>半价票</text>
							<text>凭有效证件（如退伍证，残疾证，学生证等），具体参照景区实际政策。</text>
						</view>
					</scroll-view>
				</swiper-item>
				<swiper-item>
					<scroll-view scroll-y class="scoll-y">
						<view class="cu-bar bg-white">
							<view class="action" style="margin-left: 0;">
								<text class="text-xl text-bold text-black">包含设施</text>
							</view>
						</view>
						<view class="facility-list" v-if="shopInfo.tips.value.tips_facility.value && shopInfo.tips.value.tips_facility.value.length>0">
							<view class="facility-item" v-for="(item,index) in shopInfo.tips.value.tips_facility.value" :key="index">
								<image :src="item.src" mode=""></image>
								<text>{{item.name}}</text>
							</view>
						</view>
						<view class="cu-bar bg-white">
							<view class="action" style="margin-left: 0;">
								<text class="text-xl text-bold text-black">交通攻略</text>
							</view>
						</view>
						<view class="ac-time" v-if="shopInfo.tips.value.tips_trans.value">
							{{shopInfo.tips.value.tips_trans.value}}
						</view>
						<view class="cu-bar bg-white">
							<view class="action" style="margin-left: 0;">
								<text class="text-xl text-bold text-black">景点介绍</text>
							</view>
						</view>
						<view class="">
							<u-parse :content="shopInfo.desc" v-if="shopInfo.desc!=''" @preview="preview" @navigate="navigate"></u-parse>
						</view>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
		<view class="use-btn">
			<view class="" @click="makePhone">
				<image src="https://xarkbucket.oss-cn-hangzhou.aliyuncs.com/%E5%85%8D%E5%8D%95%E9%80%9AApp/tour-phone.png" mode=""></image>
				<text>联系商家</text>
			</view>
			<view class="bg-colorP" @click="navBack">
				去购买
			</view>
		</view>
	</view>
</template>

<script>
	import uParse from '@/components/u-parse/u-parse.vue'
	export default {
		components: {
			uParse
		},
		data() {
			return {
				CustomBar: this.CustomBar,
				shopInfo: {},
				business_id: '',
				navTitle: '',
				winHeight: '',
				// 测试数据
				tabbar: ["购票须知", "景点详情"],
				currentTab: 0, //预设当前项的值
			}
		},
		onLoad(options) {
			this.business_id = options.busId
			this.currentTab = Number(options.adress)
			this.getDetail()
			const that = this;
			setTimeout(() => {
				uni.getSystemInfo({
					success: function(res) {
						let winHeight = res.windowHeight - that.CustomBar - 44;
						that.winHeight = winHeight;
					}
				})
			}, 10)
		},
		methods: {
			// 拨打商户电话
			makePhone() {
				uni.makePhoneCall({
					phoneNumber: this.shopInfo.phone
				})
			},
			navBack(){
				uni.navigateBack({
					delta:1
				})
			},
			preview(src, e) {
				// do something
			},
			navigate(href, e) {
				// do something
			},
			// 滚动切换标签样式
			switchTab: function(e) {
				let that = this;
				this.currentTab = e.detail.current;
				this.checkCor();
			},
			// 点击标题切换当前页时改变样式
			swichNav: function(e) {
				let cur = e.currentTarget.dataset.current;
				if (this.currentTab == cur) {
					return false;
				} else {
					this.currentTab = cur
				}
			},
			//判断当前滚动超过一屏时，设置tab标题滚动条。
			checkCor: function() {
				if (this.currentTab > 3) {
					//这里距离按实际计算
					this.scrollLeft = 300
				} else {
					this.scrollLeft = 0
				}
			},
			getDetail() {
				var that = this
				this.$request({
					url: '/Shop/getTravelShopDetail',
					data: {
						business_id: that.business_id
					},
					success: res => {
						if (res.data.status == 1) {
							var result = res.data.data
							that.navTitle = result.name
							result.tips.value.tips_best_time.name = result.tips.value.tips_best_time.name.indexOf('最佳') > -1 ? result.tips
								.value.tips_best_time.name.substr(2, 5) : result.tips.value.tips_best_time.name
							that.shopInfo = result
						}
						uni.hideLoading()
					},
					fail: () => {},
					complete: () => {}
				});
			},
		}
	}
</script>

<style>
	.wxParse .p {
		margin: 0.5em 0 !important
	}
</style>
<style>
	@import url("../components/u-parse/u-parse.css");

	page {
		background: #FFFFFF;
	}

	.division {
		border-top: solid 1rpx #efefef;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}

	.ticket-content {
		width: 100%;
		overflow: hidden
	}

	.tab-content {
		min-height: 610rpx;
	}


	/*tabbar start*/
	::-webkit-scrollbar {
		width: 0;
		height: 0;
		color: transparent;
	}

	.tab-view::before {
		content: '';
		border-bottom: 1upx solid #eaeef1;
		-webkit-transform: scaleY(0.5);
		transform: scaleY(0.5);
	}

	.tab-view {
		width: 100%;
		height: 88upx;
		overflow: hidden;
		background: #fff;
		display: flex;
		justify-content: center;
		border-bottom: solid 1rpx #efefef;
		box-sizing: border-box;
	}

	.tab-bar-item {
		height: 88upx;
		width: 123upx;
		line-height: 88upx;
		text-align: center;
		box-sizing: border-box;
		background-color: #ffffff;
		border-bottom: solid 6rpx transparent;
		box-sizing: border-box;
		color: #333333;
		font-size: 30rpx;
	}

	.tab-bar-item:nth-child(1) {
		margin-right: 252rpx;
	}

	.active {
		border: none;
		border-bottom: solid 6rpx #F34930;
		font-weight: bold;
	}

	/*tabbar end*/
	.scoll-y {
		height: 100%;
		padding: 0 24rpx;
		box-sizing: border-box;
	}

	.h-time {
		margin-bottom: 20rpx;
	}

	.time {
		width: 100%;
		display: flex;
		height: 88rpx;
		border-radius: 4rpx;
		display: flex;
		align-items: center;
		background-color: #efefef;
	}

	.time>view:nth-child(1) {
		width: 100rpx;
		font-size: 28rpx;
		text-align: center;
	}

	.time>view:nth-child(2) {
		flex: 1;
		font-size: 26rpx;
		text-align: left;
	}

	.ac-time {
		display: flex;
		font-size: 28rpx;
		color: #666666;
		line-height: 38rpx;
	}

	.ac-time>text {
		font-size: 26rpx;
		color: #666666;
		display: inline-block;
	}

	.ac-time>text:nth-child(1) {
		width: 140rpx;
		margin-bottom: 20rpx;
	}

	.ac-time>text:nth-child(2) {
		flex: 1;
	}

	.facility-list {
		width: 100%;
		display: flex;
		flex-wrap: wrap;
	}

	.facility-list .facility-item {
		width: 33.33%;
		height: 35rpx;
		display: flex;
		align-items: center;
		margin-bottom: 20rpx;
	}

	.facility-list .facility-item image {
		width: 28rpx;
		height: 28rpx;
		margin-right: 20rpx;
	}

	.facility-list .facility-item text {
		font-size: 28rpx;
		color: #666666;
	}

	/* 操作栏 */
	.use-btn {
		width: 100%;
		height: 88rpx;
		display: flex;
		justify-content: space-between;
		position: fixed;
		bottom: 0;
		left: 0;
		border-top: solid 1rpx #efefef;
	}

	.use-btn>view:nth-child(1) {
		width: 290rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		background: #fff;
	}

	.use-btn>view:nth-child(1) image {
		width: 36rpx;
		height: 33rpx;
		margin-right: 20rpx;
	}

	.use-btn>view:nth-child(1) text {
		font-size: 32rpx;
		color: #666666;
	}

	.use-btn>view:nth-child(2) {
		flex: 1;
		font-size: 32rpx;
		color: #fefefe;
		text-align: center;
		line-height: 88rpx;
	}
</style>
